home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 13
/
Mac Magazin and MacEasy Magazine CD - Issue 13.iso
/
Wissenschaft & Technik
/
ResAnomaly dist
/
SpinCursorsLib
/
SpinCursorLib.cp
< prev
next >
Wrap
Text File
|
1995-08-04
|
1KB
|
75 lines
/*
File: SpinCursorLib.cp
Contains: Cursor spinning routines.
Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
Version: 1.0
History: ckt August 2, 1995 created.
*/
#ifdef __powerc
#pragma traceback on
#endif
#include "SpinCursorLib.h"
CursorSet::CursorSet(const short inStartID, const short inNumCursors)
:mYCursors(sizeof(CursHandle))
{
mCursorIterator = 1;
mCurrentCursor = NULL;
// * grab cursors
CursHandle ourCursor;
for(short i = inStartID; i <= (inStartID + inNumCursors - 1); i++)
{
ourCursor = (CursHandle)GetResource('CURS', i);
ThrowIfNULL_(ourCursor);
mYCursors.InsertItemsAt(1, 1, &ourCursor);
}
mLastTicks = TickCount();
}
CursorSet::~CursorSet()
{
InitCursor();
CursHandle ourCurs;
while(mYCursors.GetCount() > 0)
{
if(mYCursors.FetchItemAt(1, &ourCurs))
{
ReleaseResource((Handle)ourCurs);
}
mYCursors.RemoveItemsAt(1, 1);
}
}
// * rotate the cursor
void CursorSet::Spin()
{
if((TickCount() - mLastTicks) > kMinSpinTicks) // * prevent cursor flash
{
if(mCurrentCursor)
HUnlock((Handle)mCurrentCursor);
if(mCursorIterator++ > mYCursors.GetCount())
mCursorIterator = 1;
if(mYCursors.FetchItemAt(mCursorIterator, &mCurrentCursor))
{
HLockHi((Handle)mCurrentCursor);
SetCursor(*mCurrentCursor);
}
mLastTicks = TickCount();
}
}